#!/bin/bash

# 判断是否设置环境变量 $ZBP_BASE_PATH
if [ -z "$ZBP_BASE_PATH" ]; then
    echo "环境变量 ZBP_BASE_PATH 未设置"
    exit 1
fi

yum install -y gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel libpcap-devel xz-devel libffi-devel zlib* wget make

cd $ZBP_BASE_PATH/zbp/software
wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz
tar -zxvf Python-3.8.5.tgz
cd Python-3.8.5

./configure --prefix=/usr/local/python3 --enable-optimizations
make -j $(nproc) && make install

# 添加软链接
ln -s /usr/local/python3/bin/python3.8 /usr/bin/python38
ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3

# 龙蜥8时可能是
#ln -s /usr/local/bin/python3.8 /usr/bin/python38
#ln -s /usr/local/bin/pip3.8 /usr/bin/pip3

python38 -V
pip3 -V

echo "Python 3.8.5 安装完成"